package com.herench.bs.handler;


import com.herench.bs.agent.IOutpatientClinicAgent;
import com.herench.bs.annotation.Handler;
import com.herench.bs.support.AbstractMessageHandler;
import com.herench.bs.support.RequestMessage;
import com.herench.bs.support.ResponseMessage;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import java.util.Map;

/**
 * com.herench.bs.handler
 * Created by wangwenkai on 2017/09/18/14:53
 *
 * @Software: IntelliJ IDEA
 */
@Component
@Handler(code = "100712",name="取消预约")
public class CancelAppointmentHandler extends AbstractMessageHandler{
    @Override
    protected ResponseMessage innerHandler(RequestMessage requestMessage) throws Exception {
        ResponseMessage responseMessage = new ResponseMessage(requestMessage.getId());
        String channelCode = requestMessage.getArgsPropertyStringValue("sysCode");
        Assert.notNull(channelCode,"sysCode 不能为空！");
        String recordId = requestMessage.getArgsPropertyStringValue("recordId");
        Assert.notNull(recordId,"recordId 不能为空！");
        String hospitalCode = getCleverClinicContext().getHospitalCodeByChannelCode(channelCode);
        IOutpatientClinicAgent iOutpatientClinicAgent = getCleverClinicContext().getApplicationContext().getBean(IOutpatientClinicAgent.class);
        Map<String,Object> resMap = iOutpatientClinicAgent.doCancelAppointByRecordId(channelCode,hospitalCode,recordId);
        responseMessage.setData(resMap);
        getPropertiesFromInvokerResultMap(responseMessage,resMap);
        return responseMessage;
    }
}
